package top.chengdongqing.mishop.order.job

import org.apache.logging.log4j.LogManager
import org.quartz.Job
import org.quartz.JobExecutionContext
import top.chengdongqing.mishop.order.OrderService

class OrderCancellationJob(
    private val orderService: OrderService
) : Job {
    private val log = LogManager.getLogger(OrderCancellationJob::class.java)

    override fun execute(context: JobExecutionContext) {
        val orders = orderService.cancelAllUnpaidOrders()
        val orderNumbers = orders.map { it.orderNumber }
        log.info("定时取消未支付的订单：{}，下次触发时间：{}", orderNumbers, context.nextFireTime)
    }
}